% computing the temporal spectrum in cases of homogeneous assumption
function W_aj = temporal_spectrum(params,Z)
% params: parameters
% Z: matrix for saving j, n and m

if params.sp == 1
   msg = 'Error, params.multilayer should be equals to 1 if params.sp = 1';
   error(msg);
end

W_V = params.W_V;
r0 = params.r0;
lambda = params.lambda;
Cn2 = params.Cn2;
L = params.L;
D = params.D;
t_miu = params.t_miu; % time frequency (half)
f_y = params.f_y; % spatial frequency
L0 = params.L0; % Outer scale
l0 = params.l0; % Inner scale

[t_miu2, f_y2] = meshgrid(t_miu/W_V, f_y);
QM = FourierZnkPlns(Z, t_miu2, f_y2, D);

% computing the normalized spectrum
fun_cal = (abs(QM).^(2)).*(((t_miu2).^2+(f_y2).^2+L0^(-2)).^(-11/6))...
            .*exp(-(2*pi*l0/5.92)^2*((t_miu2).^2+(f_y2).^2));
cal_integral = sum(fun_cal,1)*(1/D); % 积分离散求和
F_aj = 0.00969*(2*pi/lambda)^2*cal_integral;
W_aj = (L*Cn2/W_V)*F_aj;
% W_aj = 0.0229*r0^(-5/3)/W_V *cal_integral;

% end of the function
end
